using System;
using System.Device.Location;
using System.Runtime.Serialization;
namespace Microsoft.Phone.Controls.Maps.Platform
{
	[DataContract(Namespace = "http://dev.virtualearth.net/webservices/v1/common")]
	public class Location : IFormattable
	{
		[DataMember]
		public double Latitude
		{
			get;
			set;
		}
		[DataMember]
		public double Longitude
		{
			get;
			set;
		}
		[DataMember]
		public double Altitude
		{
			get;
			set;
		}
		string IFormattable.ToString(string format, IFormatProvider provider)
		{
			return string.Format(provider, string.Concat(new string[]
			{
				"{0:",
				format,
				"},{1:",
				format,
				"},{2:",
				format,
				"}"
			}), new object[]
			{
				this.Latitude,
				this.Longitude,
				this.Altitude
			});
		}
		public override string ToString()
		{
			return this.ToString(null, null);
		}
		public string ToString(IFormatProvider provider)
		{
			return this.ToString(null, provider);
		}
		public static implicit operator GeoCoordinate(Location obj)
		{
			GeoCoordinate geoCoordinate = new GeoCoordinate();
			geoCoordinate.set_Latitude(obj.Latitude);
			geoCoordinate.set_Longitude(obj.Longitude);
			geoCoordinate.set_Altitude(obj.Altitude);
			return geoCoordinate;
		}
		public static implicit operator Location(GeoCoordinate obj)
		{
			return new Location
			{
				Latitude = obj.get_Latitude(),
				Longitude = obj.get_Longitude(),
				Altitude = double.IsNaN(obj.get_Altitude()) ? 0.0 : obj.get_Altitude()
			};
		}
	}
}
